﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
/// <summary>
/// Summary description for CategoryDAL
/// </summary>
public class CategoryDAL
{
    DatabaseAccess dba = new DatabaseAccess();

	public CategoryDAL()
	{
		//
		// TODO: Add constructor logic here
		//
	}

    public DataTable GetAllCategory()
    {
        return dba.executeSelect("proc_GetCategory");
    }
    public DataTable GetCategoryID(String cat_name)
    {
        SqlParameter[] paramList = new SqlParameter[1];
        paramList[0] = new SqlParameter("@cat_name",SqlDbType.NVarChar,50);
        paramList[0].Value = cat_name;
        return dba.executeSelect("proc_GetcategoryByNAME",paramList);
    }
    public bool UpdateCategoty(Category objCategory)
    {
        SqlParameter[] paramList = new SqlParameter[3];
        paramList[0] = new SqlParameter("@cat_id",SqlDbType.Int);
        paramList[0].Value = objCategory.CatID;
        paramList[1] = new SqlParameter("@cat_name",SqlDbType.NVarChar,50);
        paramList[1].Value = objCategory.CatName;
        paramList[2] = new SqlParameter("@cat_description",SqlDbType.NVarChar,200);
        paramList[2].Value = objCategory.CatDescription;
        return dba.executeUpdate("proc_UpdateCategory", paramList);
    }
    public bool DeleteCategory(int catID)
    {
        SqlParameter[] paramList = new SqlParameter[1];
        paramList[0] = new SqlParameter("@cat_id",SqlDbType.Int);
        paramList[0].Value = catID;
        return dba.executeUpdate("proc_DeleteCategory",paramList);
    }
    public bool AddCategoty(Category objCategory)
    {
        SqlParameter[] paramList = new SqlParameter[2];
        paramList[0] = new SqlParameter("@cat_name", SqlDbType.NVarChar, 50);
        paramList[0].Value = objCategory.CatName;
        paramList[1] = new SqlParameter("@cat_description", SqlDbType.NVarChar, 200);
        paramList[1].Value = objCategory.CatDescription;
        return dba.executeUpdate("proc_AddCategory", paramList);
    }
}
